
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <script type="text/javascript" src="../../output/js/jquery.js"></script>
    <script type="text/javascript" src="../../output/js/general.js"></script>
    <script type="text/javascript">
    $(document).ready(function(){
        $("#weeknum").submit(function(event){
            event.preventDefault();
            var $form = $( this ),
                term_year = $form.find( 'select[name="year"]' ).val(),
                term_month= $form.find( 'select[name="month"]' ).val(),
                term_day= $form.find( 'select[name="day"]' ).val(),
                term_submit= $form.find( 'select[name="submit"]' ).val(),
                url  = $form.attr( 'action' );
                $.post( url, { year: term_year,month:term_month,day:term_day,submit:term_submit },
                    function( data ) {
                        $( "#result" ).empty().append( "schedule on week"+data );
                        $("#result").attr("href","get_weekly_schedule?weeknum="+data);
                    }
                );
        });
    });
    </script>
</head>
<body>
        <!-- <form action="a" id="searchForm">
        <input type="text" name="s" placeholder="Search..." />
        <input type="text" name="ss" placeholder="Search..." />
        <input type="submit" value="submit" />
        </form> -->
        <!-- the result of the search will be rendered inside this div -->

        <div>
            <div>
                <p>today is week <?php echo date("W");?></p>
            </div>
            <div>
                <form id="weeknum" action="http://localhost/wse/index.php/schedule/get_weeknum_by_date" method="post">
                    <p>time:<select id="sYear" size="1" onChange="createSelect()" name='year'></select> 
                                <select id="sMonth" size="1" onChange="createSelect()" name='month'></select> 
                                <select id="sDay" size="1" name='day'></select> 
                    </p>
                    <input id="date" type="submit" value="submit" name="submit"/>
                </form>
            </div>
            <div>
                 <a id="result"></a>
            </div>
        </div>

        <hr>
       <div>
            <table border="2">
            <tr>
            <th></th>
            <?php foreach ($date_info as $item): ?>
            <th><?php echo $item;?></th>
            <?php endforeach; ?>


            </tr>
            <tr>
            <th>Time</th>
            <th>Monday</th>
            <th>Tuesday</th>
            <th>Wednesday</th>
            <th>Thursday</th>
            <th>Friday</th>
            <th>Saturday</th>
            <th>Sunday</th>
            </tr>

            <?php for($j=0;$j<=11;$j++):?>
            <tr>
                <?php for($i=0;$i<=7;$i++):?>
                    <?php if($i==0):?>
                    <td><?php echo $j+9;?>:00</td>
                    <?php else:?>
                    <td><?php $x=array_shift($query);echo $x?></td>
                    <?php endif; ?>
                <?php endfor;?>
            <?php endfor;?>
            </tr>
            </table>
        </div>
    <hr>
    <div>
    <form action="http://localhost/wse/index.php/schedule/get_weekly_schedule?<?php echo $_SERVER["QUERY_STRING"];?>" method="post">
        <select name="date">
            <?php foreach ($date_info as $item): ?>
            <option value="<?php echo $item;?>"><?php echo $item;?></option>
            <?php endforeach; ?>
        </select>
        <select name="time">
            <?php for($j=0;$j<=11;$j++):?>
            <option value="<?php echo $j+9;?>"><?php echo $j+9;?>:00</option>
             <?php endfor;?>
        </select>
        <input type="submit" value="search" name="search"></button>
    </form>
    </div>
    

    <div> <?php if(isset($_POST['search'])):?>
        <p>您所查询的是<?php echo $detail->Unit;?>单元，当前课程<?php if($detail->avalible==1):?>剩余<?php echo 4-$detail->people_count;?>个位置<?php else:?>当前单元人数已满</p><?php endif; ?>
          <?php endif; ?>
    </div>
</body>
<script type="text/javascript">createSelect(1);</script>
</html>



